//
//  PopoverContentViewController.m
//  KxMenuExample
//
//  Created by GZMLUser on 14-10-31.
//  Copyright (c) 2014年 Konstantin Bukreev. All rights reserved.
//

#import "PopoverContentViewController.h"
#import "KxMenu.h"

@interface PopoverContentViewController ()

@end

@implementation PopoverContentViewController

- (instancetype)initWithItems:(NSArray *)items
{
    if ([super init]) {
        
        [self setContentViewSizeByItems:items];
    }
    return self;
}



// 通过menuView设置控制器大小
- (void)setContentViewSizeByItems:(NSArray *)items
{
    KxMenuView *menuView = [[KxMenuView alloc]init];

    UIView *contentView = [menuView getContentViewByItems:items];
    
    // 设置控制器对应popover 大小
    self.contentSizeForViewInPopover = CGSizeMake(CGRectGetWidth(contentView.bounds), CGRectGetHeight(contentView.bounds));
    
    // 显示菜单列表到当前控制器上
    [KxMenu showMenuInView:self.view fromRect:CGRectZero menuItems:items];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

@end
